package com.ymatou.ordersync.api.testcase;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Random;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.operate.trading.api.parameter.BatchNoNeedPostPayBean;
import com.ymatou.operate.trading.api.parameter.ChangeOrderNoteBean;
import com.ymatou.operate.trading.api.parameter.RefundBillInfoBean;
import com.ymatou.operate.trading.api.parameter.RefundProductDetailBean;
import com.ymatou.operate.trading.api.parameter.SalesRefundStatusSyncBean;
import com.ymatou.operate.trading.api.service.BatchNoNeedPostPayCall;
import com.ymatou.operate.trading.api.service.ChangeOrderNoteCall;
import com.ymatou.operate.trading.api.service.SalesRefundStatusSyncCall;
import com.ymt.base.YmatouEasyCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.OrderCallService;
import com.ymttest.common.enums.CancelOrderTypeEnum;
import com.ymttest.common.enums.LogisticsTypeEnum;
import com.ymttest.common.enums.SalesRefundStatusEnum;
import com.ymttest.database.mongo.YMatouSellerOrderAddInfoWapper;
import com.ymttest.database.mongo.YMatouSellerOrderWapper;
import com.ymttest.database.sqlwapper.DefaultWapper;
import com.ymttest.database.sqlwapper.YmtOOrderNoteWapper;
import com.ymttest.database.sqlwapper.YmtOrdersWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;
import com.ymttest.utils.constant.ECode;

/**
 *  
 */
@TestSuite
public class Ts_OrderSync {
	private static OrderCallService orderService;
	private static YMatouSellerOrderWapper  sellerorderwapper;
	private static YMatouSellerOrderAddInfoWapper sellerOrderAddInfoWapper;
	private static int LogisticsType=LogisticsTypeEnum.SailProtect.getValue();
	/**
	 * 年到毫秒的日期时间
	 */
	private static String YMDHMSS = "yyyy-MM-dd HH:mm:ss.SSS";
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("订单同步消息指令m2c端");
	}

	@Before
	public void caseUp() {
		orderService = new OrderCallService();
		try {
			sellerorderwapper=new YMatouSellerOrderWapper();
			sellerOrderAddInfoWapper = new YMatouSellerOrderAddInfoWapper();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult("OrderSync");
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	
	@SuppressWarnings("rawtypes")
	private String getRemarkLevelFromMssql(Object iOrderId, Object iUserId) {
		String remarkLevel = "null";
		List<Map> notes = new YmtOOrderNoteWapper().selectRecordsByOrderIdUserId(
				iOrderId, iUserId);
		if (notes.size() > 0) {
			remarkLevel = String.valueOf(notes.get(0).get("iRemarkLevel"));
		}
		return remarkLevel;
	}

	// m2c 下单交易全流程
	public void m2cTrading() {
		try {
			orderService = new OrderCallService();
			// 创建订单
			Map map = orderService.createM2cOrder();
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
			// 买家付款
			orderService.orderPayRequest(userId, totalPrice, tradingId);
			// 接单
			orderService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderService.dispatched(orderId, sellerId);
			// 确认收货
			orderService.confirmReceive(sellerId, orderId);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
		
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_001() {
		Logger.start(true,"m2c创建订单");
		try {
			Logger.comment("前置数据准备");		
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
            Map m1=new DefaultWapper().selectTrdSellerProductNames(sellerId,TestDataManager.getMD5("接口自动化测试Test".toLowerCase().getBytes()));
            int userTimes1=(Integer)m1.get("UsedTimes");
			// 创建订单
			Map map = orderService.createM2cOrder();
			int orderId = (Integer) map.get("orderId");
			//int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额		
			// 添加订单的备注
			ChangeOrderNoteBean changeordernotebean = new ChangeOrderNoteBean();
			ChangeOrderNoteCall changeordernotecall = new ChangeOrderNoteCall();
			changeordernotebean.setOrderId(orderId);
			changeordernotebean.setRemarkContent("备注:"+orderId);
			changeordernotebean.setUserId(sellerId);
			changeordernotebean.setRemarkLevel(2);
			// 发送时间
			changeordernotebean.setRemarkTime(YMTDateUtil.getSysTime());
			changeordernotecall.setData(changeordernotebean);
			changeordernotecall.callService();
			Logger.verifyEquals(ECode.SUCCESS, changeordernotecall.getCode(), "验证BCode");
			Logger.comment("前置数据准备结束");
			//检查点
			Map result =null;
			int count=0;
			//重试30次, 服务config文件中配置项retry_second的值(任务间隔睡眠时间)
			while(result==null&&count<30){
				Thread.sleep(1000);
				result = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}
			Logger.comment("Mongo中查询出的订单信息:"+result.toString());
			Logger.verifyEquals(orderId, (Integer) result.get("_id"), "验证OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(1, (Integer) result.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(0, (Integer) result.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(1, (Integer) result.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(100,(Integer)result.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)result.get("Income"), "验证订单"+orderId+"的Income");
			Logger.verifyEquals(0,(Integer)result.get("DomesticDelivered"), "验证订单"+orderId+"的DomesticDelivered");	
			Thread.sleep(1000l);
			equals(new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime"),result.get("CancelT"),"验证CancelT");
			String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = result.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			List<Map> productList=(List)result.get("Products");
			Logger.verifyEquals(LogisticsType,(Integer)productList.get(0).get("Logistics"), "验证订单"+orderId+"的Logistics");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证订单"+orderId+"的PrdId");			
			//验证数据
            Map m2=new DefaultWapper().selectTrdSellerProductNames(sellerId,TestDataManager.getMD5(productName.toLowerCase().getBytes()));
            int  userTimes2=  (Integer)m2.get("UsedTimes");
            Logger.verifyEquals(1,userTimes2-userTimes1, "验证订单"+orderId+"的userTimes加一");     
            
            Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
            Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
            Logger.verifyEquals(sellerOrderCountBefore.get("Received"), sellerOrderCountAfter.get("Received"), "验证Received");
            Logger.verifyEquals(sellerOrderCountBefore.get("BuyerCancelled"), sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
            Logger.verifyEquals(sellerOrderCountBefore.get("SellerCancelled"), sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
            Logger.verifyEquals(sellerOrderCountBefore.get("SystemCancelled"), sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_002() {
		Logger.start(true,"m2c接单");
		try {
			Logger.comment("前置数据准备");
			// 创建订单
			Map map = orderService.createM2cOrder();
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额

			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			// 买家付款
			orderService.orderPayRequest(userId, totalPrice, tradingId);
			// 接单
			orderService.acceptOrder(orderId, sellerId);
			// 添加订单的备注
			ChangeOrderNoteBean changeordernotebean = new ChangeOrderNoteBean();
			ChangeOrderNoteCall changeordernotecall = new ChangeOrderNoteCall();
			changeordernotebean.setOrderId(orderId);
            changeordernotebean.setRemarkContent("备注:"+orderId);
            changeordernotebean.setUserId(sellerId);
            changeordernotebean.setRemarkLevel(1);
            // 发送时间
            changeordernotebean.setRemarkTime(YMTDateUtil.getSysTime());
            changeordernotecall.setData(changeordernotebean);
            changeordernotecall.callService();
            Logger.verifyEquals(ECode.SUCCESS, changeordernotecall.getCode(), "验证BCode");
			Logger.comment("前置数据准备结束");
			//检查点
			Map result =null;
			int count=0;
			//重试3次
			while(result==null&&count<3){
				Thread.sleep(500);
				result = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}
			Logger.comment("Mongo中查询出的订单信息:"+result.toString());
			Logger.verifyEquals(orderId, (Integer) result.get("_id"), "验证订单"+orderId+"的OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(17, (Integer) result.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(0, (Integer) result.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(1, (Integer) result.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(270,(Integer)result.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)result.get("Income"), "验证订单"+orderId+"的Income");
			Logger.verifyEquals(0,(Integer)result.get("DomesticDelivered"), "验证订单"+orderId+"的DomesticDelivered");		
			Thread.sleep(1000l);
			equals(new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime"),result.get("CancelT"),"验证订单"+orderId+"的CancelT");
			String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = result.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			List<Map> productList=(List)result.get("Products");
			Logger.verifyEquals(LogisticsType,(Integer)productList.get(0).get("Logistics"), "验证订单"+orderId+"的Logistics");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证订单"+orderId+"的PrdId");
			
			Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
            Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
            Logger.verifyEquals(sellerOrderCountBefore.get("Received"), sellerOrderCountAfter.get("Received"), "验证Received");
            Logger.verifyEquals(sellerOrderCountBefore.get("BuyerCancelled"), sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
            Logger.verifyEquals(sellerOrderCountBefore.get("SellerCancelled"), sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
            Logger.verifyEquals(sellerOrderCountBefore.get("SystemCancelled"), sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_003() {
		Logger.start(true,"m2c订单确认收货");
		try {
			Logger.comment("前置数据准备");
			// 创建订单
			Map map = orderService.createM2cOrder();
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
			
			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			// 买家付款
			orderService.orderPayRequest(userId, totalPrice, tradingId);
			// 接单
			orderService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderService.dispatched(orderId, sellerId);
			// 确认收货
			orderService.confirmReceive(sellerId, orderId);
			// 添加订单的备注
			ChangeOrderNoteBean changeordernotebean = new ChangeOrderNoteBean();
			ChangeOrderNoteCall changeordernotecall = new ChangeOrderNoteCall();
			changeordernotebean.setOrderId(orderId);
			changeordernotebean.setRemarkContent("备注:"+orderId);
			changeordernotebean.setUserId(sellerId);
			changeordernotebean.setRemarkLevel(3);
			// 发送时间
			changeordernotebean.setRemarkTime(YMTDateUtil.getSysTime());
			changeordernotecall.setData(changeordernotebean);
			changeordernotecall.callService();
			Logger.verifyEquals(ECode.SUCCESS, changeordernotecall.getCode(), "验证BCode");
			Logger.comment("前置数据准备结束");
			//检查点
			Map result =null;
			int count=0;
			//重试3次
			while(result==null&&count<3){
				Thread.sleep(500);
				result = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}
			Logger.comment("Mongo中查询出的订单信息:"+result.toString());
			Logger.verifyEquals(orderId, (Integer) result.get("_id"), "验证OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(4, (Integer) result.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(0, (Integer) result.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(1, (Integer) result.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(400,(Integer)result.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)result.get("Income"), "验证订单"+orderId+"的Income");
			Logger.verifyEquals(0,(Integer)result.get("DomesticDelivered"), "验证订单"+orderId+"的DomesticDelivered");
			Thread.sleep(1000l);
			equals(new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime"),result.get("CancelT"),"验证CancelT");
	 		String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = result.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			
			List<Map> productList=(List)result.get("Products");
			Logger.verifyEquals(LogisticsType,(Integer)productList.get(0).get("Logistics"), "验证订单"+orderId+"的Logistics");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证PrdId");
			
			Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
			Logger.verifyEquals((int)sellerOrderCountBefore.get("Received")+1, sellerOrderCountAfter.get("Received"), "验证Received");
			Logger.verifyEquals(sellerOrderCountBefore.get("BuyerCancelled"), sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SellerCancelled"), sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SystemCancelled"), sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}

	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_004() {
		Logger.start(true,"m2c订单已取消(买家取消)");
		try {
			Logger.comment("前置数据准备");
			// 创建订单
			Map map = orderService.createM2cOrder();
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
			
			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			// 买家取消
			orderService.cancelOrder(orderId, userId, CancelOrderTypeEnum.BuyerCancelOrder);
			Timestamp cancleTime = (Timestamp) new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime");
			// 添加订单的备注
			ChangeOrderNoteBean changeordernotebean = new ChangeOrderNoteBean();
			ChangeOrderNoteCall changeordernotecall = new ChangeOrderNoteCall();
			changeordernotebean.setOrderId(orderId);
			changeordernotebean.setRemarkContent("备注:"+orderId);
			changeordernotebean.setUserId(sellerId);
			changeordernotebean.setRemarkLevel(4);
			// 发送时间
			changeordernotebean.setRemarkTime(YMTDateUtil.getSysTime());
			changeordernotecall.setData(changeordernotebean);
			changeordernotecall.callService();
			Logger.verifyEquals(ECode.SUCCESS, changeordernotecall.getCode(), "验证BCode");
			Logger.comment("前置数据准备结束");
			//检查点
			Map result =null;
			int count=0;
			//重试3次
			while(result==null&&count<30){
				Thread.sleep(500);
				result = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}
			Logger.comment("Mongo中查询出的订单信息:"+result.toString());
			Logger.verifyEquals(orderId, (Integer) result.get("_id"), "验证订单"+orderId+"的OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(12, (Integer) result.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(0, (Integer) result.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(1, (Integer) result.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(-120,(Integer)result.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)result.get("Income"), "验证订单"+orderId+"的Income");
			Thread.sleep(1000l);
			equals(YMTDateUtil.getObjectFormatTime(cancleTime,YMDHMSS),YMTDateUtil.getFormatTime((Date)result.get("CancelT"), YMDHMSS) , "验证CancelT");
	 		String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = result.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			
//			Logger.verifyEquals();
			List<Map> productList=(List)result.get("Products");
			Logger.verifyEquals(LogisticsType,(Integer)productList.get(0).get("Logistics"), "验证订单"+orderId+"的Logistics");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证PrdId");
			
			Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
			Logger.verifyEquals(sellerOrderCountBefore.get("Received"), sellerOrderCountAfter.get("Received"), "验证Received");
			Logger.verifyEquals((int)sellerOrderCountBefore.get("BuyerCancelled")+1, sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SellerCancelled"), sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SystemCancelled"), sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	private void equals(Object expected,Object actual,String desc){
		if(null == expected){
			expected = "null";
		}
		if(null == actual){
			actual = "null";
		}
		Logger.verifyEquals(String.valueOf(expected), String.valueOf(actual), desc);
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_005() {
		Logger.start(true,"m2c订单已取消(卖家取消)");
		try {
			Logger.comment("前置数据准备");
			// 创建订单
			Map map = orderService.createM2cOrder();
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
			
			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			// 卖家取消
			orderService.cancelOrder(orderId, userId, CancelOrderTypeEnum.SellerCancelOrder);
			Timestamp cancleTime = (Timestamp) new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime");
			// 添加订单的备注
			ChangeOrderNoteBean changeordernotebean = new ChangeOrderNoteBean();
			ChangeOrderNoteCall changeordernotecall = new ChangeOrderNoteCall();
			changeordernotebean.setOrderId(orderId);
			changeordernotebean.setRemarkContent("备注:"+orderId);
			changeordernotebean.setUserId(sellerId);
			changeordernotebean.setRemarkLevel(5);
			// 发送时间
			changeordernotebean.setRemarkTime(YMTDateUtil.getSysTime());
			changeordernotecall.setData(changeordernotebean);
			changeordernotecall.callService();
			Logger.verifyEquals(ECode.SUCCESS, changeordernotecall.getCode(), "验证BCode");
			Logger.comment("前置数据准备结束");
			//检查点
			Map result =null;
			int count=0;
			//重试3次
			while(result==null&&count<30){
				Thread.sleep(500);
				result = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}
			Logger.comment("Mongo中查询出的订单信息:"+result.toString());
			Logger.verifyEquals(orderId, (Integer) result.get("_id"), "验证OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(13, (Integer) result.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(0, (Integer) result.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(1, (Integer) result.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(-130,(Integer)result.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)result.get("Income"), "验证订单"+orderId+"的Income");
			Thread.sleep(1000l);
			equals(YMTDateUtil.getObjectFormatTime(cancleTime,YMDHMSS),YMTDateUtil.getFormatTime((Date)result.get("CancelT"), YMDHMSS) , "验证CancelT");
			String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = result.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			
			List<Map> productList=(List)result.get("Products");
			Logger.verifyEquals(LogisticsType,(Integer)productList.get(0).get("Logistics"), "验证订单"+orderId+"的Logistics");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证PrdId");
			
			Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
			Logger.verifyEquals(sellerOrderCountBefore.get("Received"), sellerOrderCountAfter.get("Received"), "验证Received");
			Logger.verifyEquals(sellerOrderCountBefore.get("BuyerCancelled"), sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
			Logger.verifyEquals((int)sellerOrderCountBefore.get("SellerCancelled")+1, sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SystemCancelled"), sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_006() {
		Logger.start(true,"m2c订单已取消(客服取消)");
		try {
			Logger.comment("前置数据准备");
			// 创建订单
			Map map = orderService.createM2cOrder();
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
			
			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			// 系统取消
			orderService.cancelOrder(orderId, userId, CancelOrderTypeEnum.CustomerCancelOrder);
			Timestamp cancleTime = (Timestamp) new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime");	
			//检查点
			Map mongo =null;
			int count=0;
			//重试3次
			while(mongo==null&&count<3){
				Thread.sleep(500);
				mongo = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}
			Logger.comment("前置数据准备结束");
			Logger.comment("Mongo中查询出的订单信息:"+mongo.toString());
			Logger.verifyEquals(orderId, (Integer) mongo.get("_id"), "验证OrderId");
			Logger.verifyEquals(sellerId, (Integer) mongo.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) mongo.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(13, (Integer) mongo.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(0, (Integer) mongo.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(1, (Integer) mongo.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(-130,(Integer)mongo.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)mongo.get("Income"), "验证订单"+orderId+"的Income");
			Logger.verifyEquals(0,(Integer)mongo.get("DomesticDelivered"), "验证订单"+orderId+"的DomesticDelivered");		
			Thread.sleep(1000l);
			equals(YMTDateUtil.getObjectFormatTime(cancleTime,YMDHMSS),YMTDateUtil.getFormatTime((Date)mongo.get("CancelT"), YMDHMSS) , "验证CancelT");
			String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = mongo.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			List<Map> productList=(List)mongo.get("Products");
			Logger.verifyEquals(LogisticsType,(Integer)productList.get(0).get("Logistics"), "验证订单"+orderId+"的Logistics");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证PrdId");
			
			Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
			Logger.verifyEquals(sellerOrderCountBefore.get("Received"), sellerOrderCountAfter.get("Received"), "验证Received");
			Logger.verifyEquals(sellerOrderCountBefore.get("BuyerCancelled"), sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
			Logger.verifyEquals((int)sellerOrderCountBefore.get("SellerCancelled")+1, sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SystemCancelled"), sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_007() {
		Logger.start(true,"m2c支付");
		try {
			Logger.comment("前置数据准备");
			// 创建订单
			Map map = orderService.createM2cOrder();
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
			
			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			// 买家付款
			orderService.orderPayRequest(userId, totalPrice, tradingId);
			//检查点
			Map result =null;
			int count=0;
			//重试3次
			while(result==null&&count<3){
				Thread.sleep(500);
				result = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}
			Logger.comment("前置数据准备结束");
			Logger.comment("Mongo中查询出的订单信息:"+result.toString());
			Logger.verifyEquals(orderId, (Integer) result.get("_id"), "验证OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(2, (Integer) result.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(0, (Integer) result.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(1, (Integer) result.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(200,(Integer)result.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)result.get("Income"), "验证订单"+orderId+"的Income");
			Logger.verifyEquals(0,(Integer)result.get("DomesticDelivered"), "验证订单"+orderId+"的DomesticDelivered");		
			Thread.sleep(1000l);
			equals(new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime"),result.get("CancelT"),"验证CancelT");
			String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = result.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			List<Map> productList=(List)result.get("Products");
			Logger.verifyEquals(LogisticsType,(Integer)productList.get(0).get("Logistics"), "验证订单"+orderId+"的Logistics");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证PrdId");
			
			Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
			Logger.verifyEquals(sellerOrderCountBefore.get("Received"), sellerOrderCountAfter.get("Received"), "验证Received");
			Logger.verifyEquals(sellerOrderCountBefore.get("BuyerCancelled"), sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SellerCancelled"), sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SystemCancelled"), sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_008() {
		Logger.start(true,"m2c卖家发货");
		try {
			Logger.comment("前置数据准备");
			// 创建订单
			Map map = orderService.createM2cOrder();
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
			
			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			// 买家付款
			orderService.orderPayRequest(userId, totalPrice, tradingId);
			// 接单
			orderService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderService.dispatched(orderId, sellerId);
			//检查点
			Map result =null;
			int count=0;
			//重试3次
			while(result==null&&count<3){
				Thread.sleep(500);
				result = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}
			Logger.comment("前置数据准备结束");
			Logger.comment("Mongo中查询出的订单信息:"+result.toString());
			Logger.verifyEquals(orderId, (Integer) result.get("_id"), "验证OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(3, (Integer) result.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(0, (Integer) result.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(1, (Integer) result.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(300,(Integer)result.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)result.get("Income"), "验证订单"+orderId+"的Income");
			Logger.verifyEquals(0,(Integer)result.get("DomesticDelivered"), "验证订单"+orderId+"的DomesticDelivered");			
			Thread.sleep(1000l);
			equals(new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime"),result.get("CancelT"),"验证CancelT");
			String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = result.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			List<Map> productList=(List)result.get("Products");
			Logger.verifyEquals(LogisticsType,(Integer)productList.get(0).get("Logistics"), "验证订单"+orderId+"的Logistics");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证PrdId");
			
			Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
			Logger.verifyEquals(sellerOrderCountBefore.get("Received"), sellerOrderCountAfter.get("Received"), "验证Received");
			Logger.verifyEquals(sellerOrderCountBefore.get("BuyerCancelled"), sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SellerCancelled"), sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SystemCancelled"), sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_009() {
		Logger.start(true,"m2c退货退款");
		try {
			Logger.comment("前置数据准备");
			// 创建订单
			Map map = orderService.createM2cOrder();
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String catalogId = (String) map.get("catalogId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
			
			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			// 买家付款
			orderService.orderPayRequest(userId, totalPrice, tradingId);
			// 接单
			orderService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderService.dispatched(orderId, sellerId);
			// 确认收货
			orderService.confirmReceive(sellerId, orderId);
			
			//退货退款
			SalesRefundStatusSyncBean srb=new SalesRefundStatusSyncBean();
			SalesRefundStatusSyncCall src=new SalesRefundStatusSyncCall();
			RefundProductDetailBean refundProductDetail=new RefundProductDetailBean();
			refundProductDetail.setCatalogId(catalogId);
			refundProductDetail.setRefundProductNum(1);		
			List<RefundProductDetailBean> refundProductList=new ArrayList<RefundProductDetailBean>();
			refundProductList.add(refundProductDetail);
			RefundBillInfoBean refundBillInfo=new RefundBillInfoBean();		
			refundBillInfo.setApprover("autotest");
			refundBillInfo.setReason("autotest");
			//退货退款 分2步
			//1 退货，退款
			refundBillInfo.setRefundType(1);	
			refundBillInfo.setRefundProductList(refundProductList);

			srb.setOrderId(orderId);
			srb.setRefundBillNo("TF"+String.valueOf(orderId));			
			//第一步 状态为processing
			srb.setSalesRefundStatus(SalesRefundStatusEnum.Processing);
			//退全款
			srb.setRefundAmount(totalPrice);
			srb.setRefundBillInfo(refundBillInfo);
			src.setData(srb);
			Logger.comment("退货退款状态同步第一步");
			src.callService();					
			//退货退款 第二步
			refundBillInfo.setRefundType(1);	
			refundBillInfo.setRefundProductList(refundProductList);

			srb.setOrderId(orderId);
			srb.setRefundBillNo("TF"+String.valueOf(orderId));			
			//退款第二步 状态为 success
			srb.setSalesRefundStatus(SalesRefundStatusEnum.Success);
			//退款第二步 带上退款金额
			srb.setRefundAmount(totalPrice);
			srb.setRefundBillInfo(refundBillInfo);	
			src.setData(srb);	
			Logger.comment("退货退款状态同步第二步");
			src.callService();					
			//检查点
			Map result =null;
			int count=0;
			//重试3次
			Thread.sleep(2000);
			while(result==null&&count<3){
				Thread.sleep(500);
				result = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}
			Logger.comment("前置数据准备结束");
			Logger.comment("Mongo中查询出的订单信息:"+result.toString());
			Logger.verifyEquals(orderId, (Integer) result.get("_id"), "验证OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(4, (Integer) result.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(0, (Integer) result.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(1, (Integer) result.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(400,(Integer)result.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)result.get("Income"), "验证订单"+orderId+"的Income");
			Logger.verifyEquals(10,(Integer)result.get("Refund"), "验证订单"+orderId+"的Refund");
			Thread.sleep(1000l);
			equals(new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime"),result.get("CancelT"),"验证CancelT");
			String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = result.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			List<Map> productList=(List)result.get("Products");
			Logger.verifyEquals(LogisticsType,(Integer)productList.get(0).get("Logistics"), "验证订单"+orderId+"的Logistics");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证PrdId");
			
			
			Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
			Logger.verifyEquals((int)sellerOrderCountBefore.get("Received")+1, sellerOrderCountAfter.get("Received"), "验证Received");
			Logger.verifyEquals(sellerOrderCountBefore.get("BuyerCancelled"), sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SellerCancelled"), sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SystemCancelled"), sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}

	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_010() {
		Logger.start(true,"m2c确认收货前退货退款");
		try {
			Logger.comment("前置数据准备");
			// 创建订单
			Map map = orderService.createM2cOrder();
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String catalogId = (String) map.get("catalogId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
			
			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			// 买家付款
			orderService.orderPayRequest(userId, totalPrice, tradingId);
			// 接单
			orderService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderService.dispatched(orderId, sellerId);
			// 确认收货
			//orderService.confirmReceive(sellerId, orderId);	
			//退货退款
			SalesRefundStatusSyncBean srb=new SalesRefundStatusSyncBean();
			SalesRefundStatusSyncCall src=new SalesRefundStatusSyncCall();
			RefundProductDetailBean refundProductDetail=new RefundProductDetailBean();
			refundProductDetail.setCatalogId(catalogId);
			refundProductDetail.setRefundProductNum(1);		
			List<RefundProductDetailBean> refundProductList=new ArrayList<RefundProductDetailBean>();
			refundProductList.add(refundProductDetail);
			RefundBillInfoBean refundBillInfo=new RefundBillInfoBean();		
			refundBillInfo.setApprover("autotest");
			refundBillInfo.setReason("autotest");
			//退货退款 分2步
			//1 退货，退款
			refundBillInfo.setRefundType(1);	
			refundBillInfo.setRefundProductList(refundProductList);

			srb.setOrderId(orderId);
			srb.setRefundBillNo("TF"+String.valueOf(orderId));			
			//第一步 状态为processing
			srb.setSalesRefundStatus(SalesRefundStatusEnum.Processing);
			//退全款
			srb.setRefundAmount(totalPrice);
			srb.setRefundBillInfo(refundBillInfo);
			src.setData(srb);		
			Logger.comment("退货退款状态同步 第一步");
			src.callService();					
			//退货退款 第二步
			refundBillInfo.setRefundType(1);	
			refundBillInfo.setRefundProductList(refundProductList);

			srb.setOrderId(orderId);
			srb.setRefundBillNo("TF"+String.valueOf(orderId));			
			//退款第二步 状态为 success
			srb.setSalesRefundStatus(SalesRefundStatusEnum.Success);
			//退款第二步 带上退款金额
			srb.setRefundAmount(totalPrice);
			srb.setRefundBillInfo(refundBillInfo);	
			src.setData(srb);	
			Logger.comment("退货退款状态同步 第二步");
			src.callService();		
			Timestamp cancleTime = (Timestamp) new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime");	
			//检查点
			Map result =null;
			int count=0;
			//重试3次
			while(result==null&&count<3){
				Thread.sleep(500);
				result = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}
			Logger.comment("前置数据准备结束");
			Logger.comment("Mongo中查询出的订单信息:"+result.toString());
			Logger.verifyEquals(orderId, (Integer) result.get("_id"), "验证OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(12, (Integer) result.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(0, (Integer) result.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(1, (Integer) result.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(-120,(Integer)result.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)result.get("Income"), "验证订单"+orderId+"的Income");
			Logger.verifyEquals(10,(Integer)result.get("Refund"), "验证订单"+orderId+"的Refund");
			Thread.sleep(1000l);
			equals(YMTDateUtil.getObjectFormatTime(cancleTime,YMDHMSS),YMTDateUtil.getFormatTime((Date)result.get("CancelT"), YMDHMSS) , "验证CancelT");
			String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = result.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			List<Map> productList=(List)result.get("Products");
			Logger.verifyEquals(LogisticsType,(Integer)productList.get(0).get("Logistics"), "验证订单"+orderId+"的Logistics");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证PrdId");
			
			Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
			Logger.verifyEquals(sellerOrderCountBefore.get("Received"), sellerOrderCountAfter.get("Received"), "验证Received");
			Logger.verifyEquals((int)sellerOrderCountBefore.get("BuyerCancelled")+1, sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SellerCancelled"), sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SystemCancelled"), sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}

	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_011() {
		Logger.start(true,"m2c卖家发货后，模拟用户投诉维权");
		try {
			Logger.comment("前置数据准备");
			// 创建订单
			Map map = orderService.createM2cOrder();
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
			
			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			// 买家付款
			orderService.orderPayRequest(userId, totalPrice, tradingId);
			// 接单
			orderService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderService.dispatched(orderId, sellerId);
			//模拟用户发起投诉维权操作
			YmatouEasyCall  CustomerComplaintCall=new YmatouEasyCall("","POST", "JSON");	
			String CustomerComplaintString="{\"OrderId\":"+orderId+",\"IsFrozen\":1,\"UserId\":"+userId+"}";
			CustomerComplaintCall.setUrl("http://api.trading.operate.ymatou.com/api/Common/FrozenOrUnFrozen");
			CustomerComplaintCall.setData(CustomerComplaintString);
			Logger.comment("投诉维权");
			CustomerComplaintCall.callService();			
			Logger.comment("前置数据准备结束");
			//检查点
			Map result =null;
			int count=0;
			//重试3次
			while(result==null&&count<3){
				Thread.sleep(500);
				result = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}
			Logger.comment("Mongo中查询出的订单信息:"+result.toString());
			Logger.verifyEquals(orderId, (Integer) result.get("_id"), "验证OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(3, (Integer) result.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(0, (Integer) result.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(1, (Integer) result.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(300,(Integer)result.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)result.get("Income"), "验证订单"+orderId+"的Income");
			Logger.verifyEquals(0,(Integer)result.get("DomesticDelivered"), "验证订单"+orderId+"的DomesticDelivered");			
			Thread.sleep(1000l);
			equals(new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime"),result.get("CancelT"),"验证CancelT");
			String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = result.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			Logger.verifyEquals(1,(Integer)result.get("Complaint"), "验证订单"+orderId+"的Complaint");		
			List<Map> productList=(List)result.get("Products");
			Logger.verifyEquals(LogisticsType,(Integer)productList.get(0).get("Logistics"), "验证订单"+orderId+"的Logistics");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证PrdId");
			
			Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
			Logger.verifyEquals(sellerOrderCountBefore.get("Received"), sellerOrderCountAfter.get("Received"), "验证Received");
			Logger.verifyEquals(sellerOrderCountBefore.get("BuyerCancelled"), sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SellerCancelled"), sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SystemCancelled"), sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_012() {
		Logger.start(true,"m2c卖家发货后，模拟拼邮国内已发货");
		try {
			Logger.comment("前置数据准备");
			// 创建订单
			Map map = orderService.createM2cOrder();
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
			
			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			// 买家付款
			orderService.orderPayRequest(userId, totalPrice, tradingId);
			// 接单
			orderService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderService.dispatched(orderId, sellerId);
			//模拟卖家  回调拼邮国内已发货
			YmatouEasyCall  DomesticDeliveredCall=new YmatouEasyCall("","POST", "JSON");
			String DomesticDeliveredString="{\"OrderId\":"+orderId+",\"LogisticsNo\":\"ZH1111111\",\"Weight\":11,\"LogisticsCompany\":\"上海物流公司\"}";
			DomesticDeliveredCall.setUrl("http://api.trading.operate.ymatou.com/api/Notify/SyncDomesticDeliveredInfo");
			DomesticDeliveredCall.setData(DomesticDeliveredString);
			Logger.comment("拼邮国内已发货状态同步");
			DomesticDeliveredCall.callService();			
			Logger.comment("前置数据准备结束");
			//检查点
			Map result =null;
			int count=0;
			//重试3次
			while(result==null&&count<3){
				Thread.sleep(500);
				result = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}
			Logger.comment("Mongo中查询出的订单信息:"+result.toString());
			Logger.verifyEquals(orderId, (Integer) result.get("_id"), "验证OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(3, (Integer) result.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(0, (Integer) result.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(1, (Integer) result.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(300,(Integer)result.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)result.get("Income"), "验证订单"+orderId+"的Income");
			Logger.verifyEquals(1,(Integer)result.get("DomesticDelivered"), "验证订单"+orderId+"的DomesticDelivered");			
			Thread.sleep(1000l);
			equals(new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime"),result.get("CancelT"),"验证CancelT");
			String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = result.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			List<Map> productList=(List)result.get("Products");
			Logger.verifyEquals(LogisticsType,(Integer)productList.get(0).get("Logistics"), "验证订单"+orderId+"的Logistics");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证PrdId");
			
			Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
			Logger.verifyEquals(sellerOrderCountBefore.get("Received"), sellerOrderCountAfter.get("Received"), "验证Received");
			Logger.verifyEquals(sellerOrderCountBefore.get("BuyerCancelled"), sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SellerCancelled"), sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SystemCancelled"), sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_013() {
		Logger.start(true,"m2c用户付款后，模拟风控未通过");
		try {
			Logger.comment("前置数据准备");
			// 创建订单
			Map map = orderService.createM2cOrder();
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
			
			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			// 买家付款
			orderService.orderPayRequest(userId, totalPrice, tradingId);
			//模拟卖家  回调拼风控未通过
/*			URL: http://api.trading.operate.ymatou.com/api/Notify/RiskControlNotify
				风控检测未通过：{OrderId:105414523,ParamExt:{"Status":"rejected"}}
				风控检测通过：{OrderId:105414517,ParamExt:{"Status":"pass"}}
				风控检测失败：{OrderId:111111,ParamExt:{"Status":"auditing"}}
			*/

			YmatouEasyCall  RiskControlNotifyCall=new YmatouEasyCall("","POST", "JSON");
			String RiskControlNotifyString="{OrderId:"+orderId+",ParamExt:{\"Status\":\"rejected\"}}";
			RiskControlNotifyCall.setUrl("http://api.trading.operate.ymatou.com/api/Notify/RiskControlNotify");
			RiskControlNotifyCall.setData(RiskControlNotifyString);
			Logger.comment("风控检测");
			RiskControlNotifyCall.callService();			
			Logger.comment("前置数据准备结束");
			//检查点
			Map result =null;
			int count=0;
			//重试3次
			while(result==null&&count<3){
				Thread.sleep(500);
				result = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}
			Logger.comment("Mongo中查询出的订单信息:"+result.toString());
			Logger.verifyEquals(orderId, (Integer) result.get("_id"), "验证OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(18, (Integer) result.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(0, (Integer) result.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(1, (Integer) result.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(-180,(Integer)result.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)result.get("Income"), "验证订单"+orderId+"的Income");
			Logger.verifyEquals(0,(Integer)result.get("DomesticDelivered"), "验证订单"+orderId+"的DomesticDelivered");
			Thread.sleep(1000l);
			Timestamp cancleTime = (Timestamp) new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime");	
			equals(YMTDateUtil.getObjectFormatTime(cancleTime,YMDHMSS),YMTDateUtil.getFormatTime((Date)result.get("CancelT"), YMDHMSS) , "验证CancelT");
			String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = result.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			Logger.verifyEquals(-1,(Integer)result.get("Risk"), "验证Risk");			

			List<Map> productList=(List)result.get("Products");
			Logger.verifyEquals(LogisticsType,(Integer)productList.get(0).get("Logistics"), "验证订单"+orderId+"的Logistics");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证PrdId");
			
			Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
			Logger.verifyEquals(sellerOrderCountBefore.get("Received"), sellerOrderCountAfter.get("Received"), "验证Received");
			Logger.verifyEquals(sellerOrderCountBefore.get("BuyerCancelled"), sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SellerCancelled"), sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
			Logger.verifyEquals((int)sellerOrderCountBefore.get("SystemCancelled")+1, sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_014() {
		Logger.start(true,"m2c用户付款后，模拟风控通过");
		try {
			Logger.comment("前置数据准备");
			// 创建订单
			Map map = orderService.createM2cOrder();
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
			
			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			// 买家付款
			orderService.orderPayRequest(userId, totalPrice, tradingId);
			//模拟卖家  回调拼风控通过
/*			URL: http://api.trading.operate.ymatou.com/api/Notify/RiskControlNotify
				风控检测未通过：{OrderId:105414523,ParamExt:{"Status":"rejected"}}
				风控检测通过：{OrderId:105414517,ParamExt:{"Status":"pass"}}
				风控检测失败：{OrderId:111111,ParamExt:{"Status":"auditing"}}
			*/

			YmatouEasyCall  RiskControlNotifyCall=new YmatouEasyCall("","POST", "JSON");
			String RiskControlNotifyString="{OrderId:"+orderId+",ParamExt:{\"Status\":\"pass\"}}";
			RiskControlNotifyCall.setUrl("http://api.trading.operate.ymatou.com/api/Notify/RiskControlNotify");
			RiskControlNotifyCall.setData(RiskControlNotifyString);
			Logger.comment("风控检测");
			RiskControlNotifyCall.callService();			
			Logger.comment("前置数据准备结束");
		
			//检查点
			Map result =null;
			int count=0;
			//重试3次
			while(result==null&&count<3){
				Thread.sleep(500);
				result = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}
			Logger.comment("Mongo中查询出的订单信息:"+result.toString());
			Logger.verifyEquals(orderId, (Integer) result.get("_id"), "验证OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(2, (Integer) result.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(0, (Integer) result.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(1, (Integer) result.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(200,(Integer)result.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)result.get("Income"), "验证订单"+orderId+"的Income");
			Logger.verifyEquals(0,(Integer)result.get("DomesticDelivered"), "验证订单"+orderId+"的DomesticDelivered");
			Thread.sleep(1000l);
			equals(new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime"),result.get("CancelT"),"验证CancelT");
			String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = result.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			Logger.verifyEquals(2,(Integer)result.get("Risk"), "验证订单"+orderId+"的Risk");			

			List<Map> productList=(List)result.get("Products");
			Logger.verifyEquals(LogisticsType,(Integer)productList.get(0).get("Logistics"), "验证订单"+orderId+"的Logistics");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证PrdId");
			
			Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
			Logger.verifyEquals(sellerOrderCountBefore.get("Received"), sellerOrderCountAfter.get("Received"), "验证Received");
			Logger.verifyEquals(sellerOrderCountBefore.get("BuyerCancelled"), sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SellerCancelled"), sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SystemCancelled"), sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_015() {
		Logger.start(true,"m2c用户付款后，模拟风控失败");
		try {
			Logger.comment("前置数据准备");
			// 创建订单
			Map map = orderService.createM2cOrder();
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			
			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
			// 买家付款
			orderService.orderPayRequest(userId, totalPrice, tradingId);
			//模拟卖家  回调拼风控失败
/*			URL: http://api.trading.operate.ymatou.com/api/Notify/RiskControlNotify
				风控检测未通过：{OrderId:105414523,ParamExt:{"Status":"rejected"}}
				风控检测通过：{OrderId:105414517,ParamExt:{"Status":"pass"}}
				风控检测失败：{OrderId:111111,ParamExt:{"Status":"auditing"}}
			*/

			YmatouEasyCall  RiskControlNotifyCall=new YmatouEasyCall("","POST", "JSON");
			String RiskControlNotifyString="{OrderId:"+orderId+",ParamExt:{\"Status\":\"auditing\"}}";
			RiskControlNotifyCall.setUrl("http://api.trading.operate.ymatou.com/api/Notify/RiskControlNotify");
			RiskControlNotifyCall.setData(RiskControlNotifyString);
			Logger.comment("风控检测");
			RiskControlNotifyCall.callService();			
			Logger.comment("前置数据准备结束");
		
			//检查点
			Map result =null;
			int count=0;
			//重试3次
			while(result==null&&count<3){
				Thread.sleep(500);
				result = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}
			Logger.comment("Mongo中查询出的订单信息:"+result.toString());
			Logger.verifyEquals(orderId, (Integer) result.get("_id"), "验证OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(2, (Integer) result.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(0, (Integer) result.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(1, (Integer) result.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(100,(Integer)result.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)result.get("Income"), "验证订单"+orderId+"的Income");
			Logger.verifyEquals(0,(Integer)result.get("DomesticDelivered"), "验证订单"+orderId+"的DomesticDelivered");
			Logger.verifyEquals(1,(Integer)result.get("Risk"), "验证订单"+orderId+"的Risk");			
			Thread.sleep(1000l);
			equals(new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime"),result.get("CancelT"),"验证CancelT");
			String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = result.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			List<Map> productList=(List)result.get("Products");
			Logger.verifyEquals(LogisticsType,(Integer)productList.get(0).get("Logistics"), "验证Logistics");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证PrdId");
			
			Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
			Logger.verifyEquals(sellerOrderCountBefore.get("Received"), sellerOrderCountAfter.get("Received"), "验证Received");
			Logger.verifyEquals(sellerOrderCountBefore.get("BuyerCancelled"), sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SellerCancelled"), sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SystemCancelled"), sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_016() {
		Logger.start(true,"c2c创建订单");
		try {
			Logger.comment("前置数据准备");
			// 创建订单
			Map map = orderService.appSaveOrder();		
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
			
			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			//检查点
			Map result =null;
			int count=0;
			Logger.comment("前置数据准备结束");
			//重试3次
			while(result==null&&count<3){
				Thread.sleep(500);
				result = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}		
			Logger.comment("Mongo中查询出的订单信息:"+result.toString());
			Logger.verifyEquals(orderId, (Integer) result.get("_id"), "验证OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(1, (Integer) result.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(1, (Integer) result.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(0, (Integer) result.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(100,(Integer)result.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)result.get("Income"), "验证订单"+orderId+"的Income");
			Thread.sleep(1000l);
			equals(new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime"),result.get("CancelT"),"验证CancelT");
			String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = result.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			List<Map> productList=(List)result.get("Products");
			Logger.verifyEquals(3,(Integer)productList.get(0).get("Logistics"), "验证订单"+orderId+"的Logistics");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证PrdId");
			
			Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
			Logger.verifyEquals(sellerOrderCountBefore.get("Received"), sellerOrderCountAfter.get("Received"), "验证Received");
			Logger.verifyEquals(sellerOrderCountBefore.get("BuyerCancelled"), sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SellerCancelled"), sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SystemCancelled"), sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_017() {
		Logger.start(true,"c2c接单");
		try {
			Logger.comment("前置数据准备");
			// 创建订单
			Map map = orderService.appSaveOrder();
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
			
			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			// 买家付款
			orderService.orderPayRequest(userId, totalPrice, tradingId);
			// 接单
			orderService.acceptOrder(orderId, sellerId);		
			Logger.comment("前置数据准备结束");
			//检查点
			Map result =null;
			int count=0;
			//重试3次
			while(result==null&&count<3){
				Thread.sleep(500);
				result = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}
			Logger.comment("Mongo中查询出的订单信息:"+result.toString());
			Logger.verifyEquals(orderId, (Integer) result.get("_id"), "验证OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(17, (Integer) result.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(1, (Integer) result.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(0, (Integer) result.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(210,(Integer)result.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)result.get("Income"), "验证订单"+orderId+"的Income");
			Thread.sleep(1000l);
			equals(new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime"),result.get("CancelT"),"验证CancelT");
			String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = result.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			List<Map> productList=(List)result.get("Products");
			Logger.verifyEquals(3,(Integer)productList.get(0).get("Logistics"), "验证订单"+orderId+"的Logistics");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证PrdId");
			
			Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
			Logger.verifyEquals(sellerOrderCountBefore.get("Received"), sellerOrderCountAfter.get("Received"), "验证Received");
			Logger.verifyEquals(sellerOrderCountBefore.get("BuyerCancelled"), sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SellerCancelled"), sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SystemCancelled"), sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_018() {
		Logger.start(true,"c2c订单确认收货");
		try {
			Logger.comment("前置数据准备");
			// 创建订单
			Map map = orderService.appSaveOrder();		
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
			
			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			// 买家付款
			orderService.orderPayRequest(userId, totalPrice, tradingId);
			// 接单
			orderService.acceptOrder(orderId, sellerId);
			// 卖家发起补款
			int price = 1+new Random().nextInt(50);
			BigDecimal payAmount = new BigDecimal(df.format(price));
			String postPayId = orderService.applyForPostPay(orderId, sellerId, payAmount);
			// 买家补款
			orderService.orderPostPayRequest(userId, payAmount, orderId);
			// 商家发货
			orderService.dispatched(orderId, sellerId);
			// 确认收货
			orderService.confirmReceive(sellerId, orderId);
			Logger.comment("前置数据准备结束");
			//检查点
			Map result =null;
			int count=0;
			//重试3次
			while(result==null&&count<3){
				Thread.sleep(500);
				result = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}
			Logger.comment("Mongo中查询出的订单信息:"+result.toString());
			Logger.verifyEquals(orderId, (Integer) result.get("_id"), "验证OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(4, (Integer) result.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(1, (Integer) result.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(1, (Integer) result.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(400,(Integer)result.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)result.get("Income"), "验证订单"+orderId+"的Income");
			Thread.sleep(1000l);
			equals(new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime"),result.get("CancelT"),"验证CancelT");
			String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = result.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			List<Map> productList=(List)result.get("Products");
			Logger.verifyEquals(3,(Integer)productList.get(0).get("Logistics"), "验证订单"+orderId+"的Logistics");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证PrdId");
			
			Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
			Logger.verifyEquals((int)sellerOrderCountBefore.get("Received")+1, sellerOrderCountAfter.get("Received"), "验证Received");
			Logger.verifyEquals(sellerOrderCountBefore.get("BuyerCancelled"), sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SellerCancelled"), sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SystemCancelled"), sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}

	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_019() {
		Logger.start(true,"c2c订单已取消(系统取消)");
		try {
			Logger.comment("前置数据准备");
			// 创建订单
			Map map = orderService.appSaveOrder();
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
			
			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			// 系统取消
			orderService.cancelOrder(orderId, userId, CancelOrderTypeEnum.SystemCancelOrder);
			//检查点
			Map result =null;
			int count=0;
			Logger.comment("前置数据准备结束");
			//重试3次
			while(result==null&&count<3){
				Thread.sleep(500);
				result = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}
			Logger.comment("Mongo中查询出的订单信息:"+result.toString());
			Logger.verifyEquals(orderId, (Integer) result.get("_id"), "验证OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(18, (Integer) result.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(1, (Integer) result.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(0, (Integer) result.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(-180,(Integer)result.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)result.get("Income"), "验证订单"+orderId+"的Income");
			List<Map> productList=(List)result.get("Products");
			Logger.verifyEquals(3,(Integer)productList.get(0).get("Logistics"), "验证订单"+orderId+"的Logistics");
			Thread.sleep(1000l);
			Timestamp cancleTime = (Timestamp) new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime");		
			equals(YMTDateUtil.getObjectFormatTime(cancleTime,YMDHMSS),YMTDateUtil.getFormatTime((Date)result.get("CancelT"), YMDHMSS) , "验证CancelT");
			String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = result.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证PrdId");
			
			Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
			Logger.verifyEquals(sellerOrderCountBefore.get("Received"), sellerOrderCountAfter.get("Received"), "验证Received");
			Logger.verifyEquals(sellerOrderCountBefore.get("BuyerCancelled"), sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SellerCancelled"), sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
			Logger.verifyEquals((int)sellerOrderCountBefore.get("SystemCancelled")+1, sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_020() {
		Logger.start(true,"c2c支付");
		try {
			Logger.comment("前置数据准备");
			// 创建订单
			Map map = orderService.appSaveOrder();		
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
			
			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			// 买家付款
			orderService.orderPayRequest(userId, totalPrice, tradingId);
			Logger.comment("前置数据准备结束");
			//检查点
			Map result =null;
			int count=0;
			//重试3次
			while(result==null&&count<3){
				Thread.sleep(500);
				result = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}
			Logger.comment("Mongo中查询出的订单信息:"+result.toString());
			Logger.verifyEquals(orderId, (Integer) result.get("_id"), "验证OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(2, (Integer) result.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(1, (Integer) result.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(0, (Integer) result.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(200,(Integer)result.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)result.get("Income"), "验证订单"+orderId+"的Income");
			Thread.sleep(1000l);
			equals(new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime"),result.get("CancelT"),"验证CancelT");
			String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = result.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			List<Map> productList=(List)result.get("Products");
			Logger.verifyEquals(3,(Integer)productList.get(0).get("Logistics"), "验证订单"+orderId+"的Logistics");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证PrdId");
			
			Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
			Logger.verifyEquals(sellerOrderCountBefore.get("Received"), sellerOrderCountAfter.get("Received"), "验证Received");
			Logger.verifyEquals(sellerOrderCountBefore.get("BuyerCancelled"), sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SellerCancelled"), sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SystemCancelled"), sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_021() {
		Logger.start(true,"c2c卖家申请补款");
		try {
			Logger.comment("前置数据准备");
			// 创建订单
			Map map = orderService.appSaveOrder();		
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
			
			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			// 买家付款
			orderService.orderPayRequest(userId, totalPrice, tradingId);
			// 接单
			orderService.acceptOrder(orderId, sellerId);
			// 卖家发起补款
			int price = 1+new Random().nextInt(50);
			BigDecimal payAmount = new BigDecimal(df.format(price));
			String postPayId = orderService.applyForPostPay(orderId, sellerId, payAmount);
			Logger.comment("前置数据准备结束");
			//检查点
			Map result =null;
			int count=0;
			//重试3次
			while(result==null&&count<3){
				Thread.sleep(500);
				result = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}
			Logger.comment("Mongo中查询出的订单信息:"+result.toString());
			Logger.verifyEquals(orderId, (Integer) result.get("_id"), "验证OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(16, (Integer) result.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(1, (Integer) result.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(0, (Integer) result.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(220,(Integer)result.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)result.get("Income"), "验证订单"+orderId+"的Income");
			List<Map> productList=(List)result.get("Products");
			Logger.verifyEquals(3,(Integer)productList.get(0).get("Logistics"), "验证订单"+orderId+"的Logistics");
			Thread.sleep(1000l);
			equals(new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime"),result.get("CancelT"),"验证CancelT");
			String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = result.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证PrdId");
			
			Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
			Logger.verifyEquals(sellerOrderCountBefore.get("Received"), sellerOrderCountAfter.get("Received"), "验证Received");
			Logger.verifyEquals(sellerOrderCountBefore.get("BuyerCancelled"), sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SellerCancelled"), sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SystemCancelled"), sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_022() {
		Logger.start(true,"c2c买家补款");
		try {
			Logger.comment("前置数据准备");
			// 创建订单
			Map map = orderService.appSaveOrder();		
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
			
			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			// 买家付款
			orderService.orderPayRequest(userId, totalPrice, tradingId);
			// 接单
			orderService.acceptOrder(orderId, sellerId);
			// 卖家发起补款
			int price = 1+new Random().nextInt(50);
			BigDecimal payAmount = new BigDecimal(df.format(price));
			String postPayId = orderService.applyForPostPay(orderId, sellerId, payAmount);
			// 买家补款
			orderService.orderPostPayRequest(userId, payAmount, orderId);
			Logger.comment("前置数据准备结束");
			//检查点
			Map result =null;
			int count=0;
			//重试3次
			while(result==null&&count<3){
				Thread.sleep(500);
				result = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}
			Logger.comment("Mongo中查询出的订单信息:"+result.toString());
			Logger.verifyEquals(orderId, (Integer) result.get("_id"), "验证OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(17, (Integer) result.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(1, (Integer) result.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(1, (Integer) result.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(270,(Integer)result.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)result.get("Income"), "验证订单"+orderId+"的Income");
			List<Map> productList=(List)result.get("Products");
			Logger.verifyEquals(3,(Integer)productList.get(0).get("Logistics"), "验证订单"+orderId+"的Logistics");
			Thread.sleep(1000l);
			equals(new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime"),result.get("CancelT"),"验证CancelT");
			String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = result.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证PrdId");
			
			Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
			Logger.verifyEquals(sellerOrderCountBefore.get("Received"), sellerOrderCountAfter.get("Received"), "验证Received");
			Logger.verifyEquals(sellerOrderCountBefore.get("BuyerCancelled"), sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SellerCancelled"), sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SystemCancelled"), sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_023() {
		Logger.start(true,"c2c补款取消");
		try {
			Logger.comment("前置数据准备");
			// 创建订单
			Map map = orderService.appSaveOrder();		
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
			
			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			// 买家付款
			orderService.orderPayRequest(userId, totalPrice, tradingId);
			// 接单
			orderService.acceptOrder(orderId, sellerId);
			// 卖家发起补款
			int price = 1+new Random().nextInt(50);
			BigDecimal payAmount = new BigDecimal(df.format(price));
			String postPayId = orderService.applyForPostPay(orderId, sellerId, payAmount);			
			// 商家补款取消
			orderService.cancelPostPay(orderId, sellerId);
			Logger.comment("前置数据准备结束");
			//检查点
			Map result =null;
			int count=0;
			//重试3次
			while(result==null&&count<3){
				Thread.sleep(500);
				result = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}
			Logger.comment("Mongo中查询出的订单信息:"+result.toString());
			Logger.verifyEquals(orderId, (Integer) result.get("_id"), "验证OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(17, (Integer) result.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(1, (Integer) result.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(0, (Integer) result.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(210,(Integer)result.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)result.get("Income"), "验证订单"+orderId+"的Income");
			List<Map> productList=(List)result.get("Products");
			Logger.verifyEquals(3,(Integer)productList.get(0).get("Logistics"), "验证订单"+orderId+"的Logistics");
			Thread.sleep(1000l);
			equals(new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime"),result.get("CancelT"),"验证CancelT");
			String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = result.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证PrdId");
			
			Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
			Logger.verifyEquals(sellerOrderCountBefore.get("Received"), sellerOrderCountAfter.get("Received"), "验证Received");
			Logger.verifyEquals(sellerOrderCountBefore.get("BuyerCancelled"), sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SellerCancelled"), sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SystemCancelled"), sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_024() {
		Logger.start(true,"c2c卖家发货");
		try {
			Logger.comment("前置数据准备");
			// 创建订单
			Map map = orderService.appSaveOrder();		
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
			
			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			// 买家付款
			orderService.orderPayRequest(userId, totalPrice, tradingId);
			// 接单
			orderService.acceptOrder(orderId, sellerId);
			// 卖家发起补款
			int price = 1+new Random().nextInt(50);
			BigDecimal payAmount = new BigDecimal(df.format(price));
			String postPayId = orderService.applyForPostPay(orderId, sellerId, payAmount);
			// 买家补款
			orderService.orderPostPayRequest(userId, payAmount, orderId);
			// 商家发货
			orderService.dispatched(orderId, sellerId);
			Logger.comment("前置数据准备结束");
			//检查点
			Map result =null;
			int count=0;
			//重试3次
			while(result==null&&count<3){
				Thread.sleep(500);
				result = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}
			Logger.comment("Mongo中查询出的订单信息:"+result.toString());
			Logger.verifyEquals(orderId, (Integer) result.get("_id"), "验证OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(3, (Integer) result.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(1, (Integer) result.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(1, (Integer) result.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(300,(Integer)result.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)result.get("Income"), "验证订单"+orderId+"的Income");
			List<Map> productList=(List)result.get("Products");
			Thread.sleep(1000l);
			equals(new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime"),result.get("CancelT"),"验证CancelT");
			String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = result.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			Logger.verifyEquals(3,(Integer)productList.get(0).get("Logistics"), "验证订单"+orderId+"的Logistics");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证PrdId");
			
			Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
			Logger.verifyEquals(sellerOrderCountBefore.get("Received"), sellerOrderCountAfter.get("Received"), "验证Received");
			Logger.verifyEquals(sellerOrderCountBefore.get("BuyerCancelled"), sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SellerCancelled"), sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SystemCancelled"), sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderSync_025() {
		Logger.start(true,"c2c无需补款");
		try {
			Logger.comment("前置数据准备");
			// 创建订单
			Map map = orderService.appSaveOrder();		
			int orderId = (Integer) map.get("orderId");
			int sellerId = (Integer) map.get("sellerId");
			int userId = (Integer) map.get("userId");
			int tradingId = (Integer) map.get("tradingId");
			String productName =(String) map.get("productName");
			DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
			BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
			
			Map sellerOrderCountBefore = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			// 买家付款
			orderService.orderPayRequest(userId, totalPrice, tradingId);
			// 接单
			orderService.acceptOrder(orderId, sellerId);
			BatchNoNeedPostPayBean bnnppbean = new BatchNoNeedPostPayBean();
			BatchNoNeedPostPayCall bnnppcall = new BatchNoNeedPostPayCall();
			ArrayList<Integer> list = new ArrayList<Integer>();
			list.add(orderId);		
			bnnppbean.setOrderIds(list);
			bnnppbean.setSellerId(sellerId);
			// 发送请求
			bnnppcall.setData(false,bnnppbean);
			Logger.comment("无需补款");
			bnnppcall.callService();
			Logger.comment("前置数据准备结束");
			//检查点
			Map result =null;
			int count=0;
			//重试3次
			while(result==null&&count<3){
				Thread.sleep(500);
				result = sellerorderwapper.selectOrderInfoById(orderId, sellerId);
				count++;
			}
			Logger.comment("Mongo中查询出的订单信息:"+result.toString());
			Logger.verifyEquals(orderId, (Integer) result.get("_id"), "验证OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"), "验证订单"+orderId+"的Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"), "验证订单"+orderId+"的Buyer");
			Logger.verifyEquals(17, (Integer) result.get("TradingStatus"), "验证订单"+orderId+"的TradingStatus");
			Logger.verifyEquals(1, (Integer) result.get("Type"), "验证订单"+orderId+"的Type");
			Logger.verifyEquals(1, (Integer) result.get("FullPaid"), "验证订单"+orderId+"的FullPaid");
			Logger.verifyEquals(270,(Integer)result.get("Status"), "验证订单"+orderId+"的Status");
			Logger.verifyEquals(0.0,(Double)result.get("Income"), "验证订单"+orderId+"的Income");
			List<Map> productList=(List)result.get("Products");
			Logger.verifyEquals(3,(Integer)productList.get(0).get("Logistics"), "验证订单"+orderId+"的Logistics");
			Thread.sleep(1000l);
			equals(new YmtOrdersWapper().selectAppSellerOrdersTestData(1," o.iOrderId = "+orderId).get(0).get("dCancelTime"),result.get("CancelT"),"验证CancelT");
			String expRemarklevel = getRemarkLevelFromMssql(orderId, sellerId);
			Object actualRemarkLevel = result.get("RemarkLevel");
			equals(expRemarklevel,actualRemarkLevel,"验证订单"+orderId+"的RemarkLevel的同步");
			Logger.verifyEquals(TestDataManager.getMD5(productName.toLowerCase().getBytes()),(String)productList.get(0).get("PrdId"), "验证PrdId");
			
			Map sellerOrderCountAfter = sellerOrderAddInfoWapper.selectOrderCountBySeller(sellerId);
			Logger.comment("Mongo中查询买手的订单统计信息:"+sellerOrderCountAfter.toString());
			Logger.verifyEquals(sellerOrderCountBefore.get("Received"), sellerOrderCountAfter.get("Received"), "验证Received");
			Logger.verifyEquals(sellerOrderCountBefore.get("BuyerCancelled"), sellerOrderCountAfter.get("BuyerCancelled"), "验证BuyerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SellerCancelled"), sellerOrderCountAfter.get("SellerCancelled"), "验证SellerCancelled");
			Logger.verifyEquals(sellerOrderCountBefore.get("SystemCancelled"), sellerOrderCountAfter.get("SystemCancelled"), "验证SystemCancelled");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
}